package com.baidu.mapapi;

import android.location.Location;
import android.os.Bundle;
import java.util.ArrayList;
import java.util.List;

public class MKLocationManager
{
  public static final int MK_COORDINATE_BAIDU09 = 2;
  public static final int MK_COORDINATE_GCJ = 1;
  public static final int MK_COORDINATE_WGS84 = 0;
  public static final int MK_GPS_PROVIDER = 0;
  public static final int MK_NETWORK_PROVIDER = 1;
  private Location a = null;
  private Location b = null;
  private List<LocationListener> c = new ArrayList();

  void a()
  {
    this.b = null;
  }

  boolean a(BMapManager paramBMapManager)
  {
    int i;
    if (paramBMapManager == null)
      i = 0;
    while (true)
    {
      while (true)
      {
        return i;
        Mj.k = true;
        Mj.l = true;
        this.c.clear();
        if (Mj.InitLocationCC() != 1)
          break;
        i = 1;
      }
      i = 0;
    }
  }

  void b()
  {
    Mj.DisableProviderCC(0);
    Mj.DisableProviderCC(1);
  }

  void c()
  {
    Location localLocation = getLocationInfo();
    if ((this.b == null) || (localLocation == null) || (localLocation.distanceTo(this.b) >= 0.10000000000000001D) || (localLocation.getAccuracy() != this.b.getAccuracy()) || (localLocation.getBearing() != this.b.getBearing()) || (localLocation.getSpeed() != this.b.getSpeed()) || (localLocation.getAltitude() != this.b.getAltitude()))
      for (int i = 0; i < this.c.size(); ++i)
      {
        ((LocationListener)this.c.get(i)).onLocationChanged(localLocation);
        this.b = localLocation;
      }
  }

  public boolean disableProvider(int paramInt)
  {
    int i;
    if ((paramInt != 0) && (paramInt != 1))
      i = 0;
    while (true)
    {
      return i;
      if (Mj.DisableProviderCC(paramInt) != 0)
        break;
      i = 0;
    }
    if (paramInt == 0)
      Mj.k = false;
    while (true)
    {
      do
        while (true)
          i = 1;
      while (paramInt != 1);
      Mj.l = false;
    }
  }

  public boolean enableProvider(int paramInt)
  {
    int i;
    if ((paramInt != 0) && (paramInt != 1))
      i = 0;
    while (true)
    {
      return i;
      if (Mj.EnableProviderCC(paramInt) != 0)
        break;
      i = 0;
    }
    if (paramInt == 0)
      Mj.k = true;
    while (true)
    {
      do
        while (true)
          i = 1;
      while (paramInt != 1);
      Mj.l = true;
    }
  }

  public Location getLocationInfo()
  {
    Location localLocation;
    Bundle localBundle = Mj.GetGPSStatus();
    if (localBundle == null)
    {
      localLocation = null;
      return localLocation;
    }
    if (localBundle.getInt("t") == 1)
    {
      this.a = new Location("network");
      this.a.setLatitude(localBundle.getFloat("y"));
      this.a.setLongitude(localBundle.getFloat("x"));
      this.a.setAccuracy(localBundle.getInt("r"));
    }
    while (true)
    {
      while (true)
        localLocation = this.a;
      this.a = Mj.a.a;
      this.a.setLatitude(localBundle.getFloat("y"));
      this.a.setLongitude(localBundle.getFloat("x"));
    }
  }

  public Bundle getNoitifyInternal()
  {
    return Mj.GetNoitifyInternal();
  }

  public void removeUpdates(LocationListener paramLocationListener)
  {
    this.c.remove(paramLocationListener);
  }

  public void requestLocationUpdates(LocationListener paramLocationListener)
  {
    this.c.add(paramLocationListener);
  }

  public void setLocationCoordinateType(int paramInt)
  {
    Mj.c = paramInt;
    Mj.SetLocationCoordinateType(paramInt);
  }

  public boolean setNoitifyInternal(int paramInt1, int paramInt2)
  {
    int i;
    if ((paramInt1 >= paramInt2) && (paramInt2 >= 0))
      if (Mj.SetNoitifyInternal(paramInt1, paramInt2) == 1)
        i = 1;
    while (true)
    {
      while (true)
      {
        return i;
        i = 0;
      }
      i = 0;
    }
  }
}